import os 

class datage():
    def __init__(self):
        pass
    
    def g(self, txt,options,spliter):
        txt = txt.strip()
        txt = txt.replace("*","")
        txt = txt.replace("＊","")
        
        array = txt.split("\n")

        optionsArray = options.split("-")
        optionslen = len(optionsArray)
        optionsString = "["
        for index in range(len(optionsArray)):
            optionsString += "'{}'".format(optionsArray[index])
            if(index != optionslen - 1):
                optionsString += ","
        optionsString += "]"


        result = ""
        for line in array:
            items = line.split(spliter)
            index = items[0]
            content = items[1]
            result += "\n{\n"
            result += "\tsubject: {\n"
            
            result += "\t\tno:{},\n".format(index)
            result += "\t\ttitle: '{}',\n".format(content)
            
            result += "\t\toption: "+ optionsString +"\n"

            result += "\t},\n"
            result += "\tcheckbox: [],\n"
            result += "\tmultiSelect: 0,\n"
            result += "\tisSelect: false,\n"
            result += "\tisFirst: true\n"
            result += "},"
        
        filepath = os.path.abspath('script/temp.txt')
        result = result[:-1]
        result = result.strip('\n')
        f = open(filepath,"w",encoding='UTF-8')
        f.write(result)
        f.close()

        return result
